﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using OpenTK;

namespace JAMR.Rendering
{
    public class Camera
    {
        public Matrix4 ModelView { get; set; }
        public Matrix4 Projection { get; set; }
        public Size ImageSize { get; set; }
        public Vector3 CameraLoc { get; set; }

        public Camera() 
        {
            ModelView = new Matrix4();
            Projection = new Matrix4();
            ImageSize = new Size();
        }

        public void SetModel()
        {
            SetModel(new Vector3(10, 10, 10), Vector3.Zero);
        }
        public void SetModel(Vector3 eye, Vector3 target)
        {
            Matrix4 m = Matrix4.CreateFromAxisAngle(Vector3.Zero, 0);

            Matrix4 modelview = Matrix4.LookAt(
                        eye,
                        target,
                        Vector3.UnitY);

            ModelView = modelview;

            CameraLoc = eye;
        }

        public void SetProjection()
        {
            SetProjection(ImageSize);
        }
        public void SetProjection(Size size)
        {
            SetProjection(size, 64f);
        }
        public void SetProjection(Size size, float farView)
        {
            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(
                    MathHelper.PiOver4,
                    size.Width / (float)size.Height,
                    0.1f, farView);

            Projection = projection;
        }
    }
}
